package com.hknc.btscale.fm;

import android.content.Context;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.hknc.btscale.R;
import com.hknc.btscale.adapter.GoodsAdapter;
import com.hknc.btscale.bean.GoodsBean;

import java.util.ArrayList;
import java.util.List;

public class InfoAFragment extends Fragment {
    private List<GoodsBean> mGoodsBeans;
    private RecyclerView mRecyclerView;
    private GridLayoutManager manager;
    private GoodsAdapter adapter;
    private static final String TAG = "InfoAFragment";

    public InfoAFragment(List<GoodsBean> mGoodsBeans) {
        this.mGoodsBeans = mGoodsBeans;
        Log.e(TAG, "InfoAFragment: " + mGoodsBeans.size());
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        Log.e(TAG, "onCreateView: ");
        return inflater.inflate(R.layout.fragment_info_a, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

    }

    private boolean isVisibleToUser;

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        Log.e(TAG, "setUserVisibleHint: " + isVisibleToUser);
        super.setUserVisibleHint(isVisibleToUser);
        this.isVisibleToUser = isVisibleToUser;
    }


    @Override
    public void onResume() {
        super.onResume();
        Log.e(TAG, "onResume: " + isVisibleToUser);
        if (isVisibleToUser) {
            //TODO
//            mRecyclerView = getActivity().findViewById(R.id.recycler_view);
//            adapter = new GoodsAdapter(getContext(), R.layout.item_goods, mGoodsBeans);
//            manager = new GridLayoutManager(getContext(), 5);//一行显示五条
//            mRecyclerView.setLayoutManager(manager);
//            mRecyclerView.setAdapter(adapter);

        }

    }

    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
        Log.e(TAG, "onAttach: ");
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        Log.e(TAG, "onActivityCreated: ");

    }

    @Override
    public void onStart() {
        super.onStart();
        Log.e(TAG, "onStart: ");

    }

    @Override
    public void onPause() {
        super.onPause();
        Log.e(TAG, "onPause: ");

    }

    @Override
    public void onStop() {
        super.onStop();
        Log.e(TAG, "onStop: ");

    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        Log.e(TAG, "onDestroyView: ");

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.e(TAG, "onDestroy: ");

    }

    @Override
    public void onDetach() {
        super.onDetach();
        Log.e(TAG, "onDetach: ");

    }
}